﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include<QIcon>
#include<QMenuBar>
#include<QAction>
#include<QPushButton>
#include<QWidget>
#include<QObject>
#include<QMouseEvent>
#include<QPixmap>
#include<QPainter>
#include<Qpoint>
#include<QVector>
#include <QInputDialog>
#include <QPainterPath>
#include <QMenuBar>
#include <QAction>
#include <QPushButton>
#include <QWidget>
#include <QObject>
#include <QPainter>
#include <QMouseEvent>
#include <QVector>
#include <QRect>
#include <QDebug>
#include "move.h"


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

struct Shape {
    enum Type { None, Line, Rectangle, Circle, Ellipse };

    Type type;
    QRect rect;
    QColor lineColor;
    bool isSelected;

    Shape(Type t, QRect r, QColor lc) : type(t), rect(r), lineColor(lc), isSelected(false) {}
};



class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void addShape(Shape::Type type, QRect rect, QColor lineColor)
    {
        shapes.append(Shape(type, rect, lineColor));
    }

protected:
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void mouseReleaseEvent(QMouseEvent *event);
    //virtual void mouseDoubleClickEvent(QMouseEvent *event);
    virtual void mouseMoveEvent(QMouseEvent *event);

public:
    QPoint start;
    QPoint start1;
    QPoint end;
    QPoint end1;
    QPixmap* pix;
    void paintEvent(QPaintEvent *event);
    QVector<QPoint> _line;
    bool save;
    bool isSelected = false;
    bool kg;

public:
    int type;//�жϻ�������
    double r;//半径
    QVector<Shape> shapes;
private:
    Shape* selectedShape; // 图形区
    Shape::Type selectedShapeType;
    QColor selectedLineColor;


signals:

public slots:
    void Line();//ֱ直线
    void Rect();//矩形
    void Circle();//圆形
    void Ellipse();//椭圆
    void ClearPainter();//清除
    void zoomOut();//放大选定shape
    void zoomIn();//缩小选定shape
    void moved();//打开移动对话框
    void onMove(int x,int y);//移动选定shape

private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
